﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VxiUtil
{
    public static class byteExtensions
    {
        public static string GetSubByteString(this byte[] byteArray, int start, int length)
        {
            byte[] newArray = new byte[length];
            Buffer.BlockCopy(byteArray, start, newArray, 0, length);
            return Encoding.ASCII.GetString(newArray).TrimEnd(new char[] {'\0'});
        }

        public static byte[] AppendArray(this byte[] byteArray, byte[] append)
        {
            byte[] returnArray = new byte[byteArray.Length + append.Length];
            Buffer.BlockCopy(byteArray, 0, returnArray, 0, byteArray.Length);
            Buffer.BlockCopy(append, 0, returnArray, byteArray.Length, append.Length);
            return returnArray;
        }
    }
}
